#---------------------------------------------------
# OSG CMAKE SUPPORT
# (C) by Michael Wagner, mtw@shared-reality.com 2005
# (C) Eric Wing, Luigi Calori and Robert Osfield 2006-2007
#---------------------------------------------------

PROJECT(OSG_PLUGINS_MASTER)

IF(NOT DYNAMIC_OPENSCENEGRAPH)
    ADD_DEFINITIONS(-DOSG_LIBRARY_STATIC)
ENDIF()

IF(NOT MSVC)
    SET(LIBRARY_OUTPUT_PATH "${LIBRARY_OUTPUT_PATH}/${OSG_PLUGINS}")
    SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${OSG_PLUGINS}")
ENDIF()

SET(CMAKE_SHARED_MODULE_PREFIX ${OSG_PLUGIN_PREFIX})

IF(MSVC80 OR MSVC90)
    IF(NOT OSG_MSVC_GENERATE_PLUGINS_AND_WRAPPERS_MANIFESTS)
        SET(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} /MANIFEST:NO")
    ENDIF()
ENDIF()

SET(TARGET_DEFAULT_PREFIX "osgdb_")
SET(TARGET_DEFAULT_LABEL_PREFIX "Plugins")
SET(TARGET_COMMON_LIBRARIES
    OpenThreads
    osg
    osgDB
    osgUtil
)

############################################################
#
#  NodeKit/Psudo loader plugins
#
ADD_SUBDIRECTORY(osga)
ADD_SUBDIRECTORY(rot)
ADD_SUBDIRECTORY(scale)
ADD_SUBDIRECTORY(trans)
ADD_SUBDIRECTORY(normals)
ADD_SUBDIRECTORY(revisions)
ADD_SUBDIRECTORY(view)
ADD_SUBDIRECTORY(shadow)
ADD_SUBDIRECTORY(terrain)

############################################################
#
#  Main native plugins
#
ADD_SUBDIRECTORY(osg)
ADD_SUBDIRECTORY(ive)

############################################################
#
#  Viewer plugins
#
ADD_SUBDIRECTORY(cfg)

############################################################
#
#  Shader plugins
#
ADD_SUBDIRECTORY(glsl)

############################################################
#
#  Image plugins
#

ADD_SUBDIRECTORY(rgb)
ADD_SUBDIRECTORY(bmp)
# playbook edit #ADD_SUBDIRECTORY(pnm)
# ADD_SUBDIRECTORY(dds)
# ADD_SUBDIRECTORY(tga)
# playbook edit #ADD_SUBDIRECTORY(hdr)
# playbook edit #ADD_SUBDIRECTORY(dot)
# playbook edit #ADD_SUBDIRECTORY(vtf)

IF(JPEG_FOUND)
    ADD_SUBDIRECTORY(jpeg)
ENDIF()
#IF(JASPER_FOUND)
#    ADD_SUBDIRECTORY(jp2)
#ENDIF()
#IF(OPENEXR_FOUND AND ZLIB_FOUND AND OSG_CPP_EXCEPTIONS_AVAILABLE)
#    ADD_SUBDIRECTORY(exr)
#ENDIF()
IF(GIFLIB_FOUND)
    ADD_SUBDIRECTORY(gif)
ENDIF()
IF(PNG_FOUND AND OSG_CPP_EXCEPTIONS_AVAILABLE)
    ADD_SUBDIRECTORY(png)
ENDIF()
IF(TIFF_FOUND AND OSG_CPP_EXCEPTIONS_AVAILABLE)
    ADD_SUBDIRECTORY(tiff)
ENDIF()
# playbook edit #IF(GDAL_FOUND)
# playbook edit #    ADD_SUBDIRECTORY(gdal)
# playbook edit #    ADD_SUBDIRECTORY(ogr)
# playbook edit #ENDIF()
#IF(GTA_FOUND AND OSG_CPP_EXCEPTIONS_AVAILABLE)
#    ADD_SUBDIRECTORY(gta)
#ENDIF()


############################################################
#
# 3D Image plugins
#
#IF(DCMTK_FOUND AND ZLIB_FOUND)
#    ADD_SUBDIRECTORY(dicom)
#ELSE()
#    IF(ITK_FOUND)
#        ADD_SUBDIRECTORY(dicom)
#    ENDIF()
#ENDIF()

############################################################
#
#  3rd party 3d plugins
#

#ADD_SUBDIRECTORY(3dc)

#ADD_SUBDIRECTORY(p3d)

IF(CURL_FOUND)
    ADD_SUBDIRECTORY(curl)
ENDIF()

IF(ZLIB_FOUND)
    ADD_SUBDIRECTORY(gz)
ENDIF()

#IF(NOT OSG_GLES1_AVAILABLE AND NOT OSG_GLES2_AVAILABLE)
#    IF(INVENTOR_FOUND)
#        ADD_SUBDIRECTORY(Inventor)
#    ENDIF()
#
#    IF(PERFORMER_FOUND)
#        ADD_SUBDIRECTORY(pfb)
#    ENDIF()
#ENDIF()

#IF(OPENVRML_FOUND AND OSG_CPP_EXCEPTIONS_AVAILABLE)
#    ADD_SUBDIRECTORY(vrml)
#ENDIF()

#IF(COLLADA_FOUND AND OSG_CPP_EXCEPTIONS_AVAILABLE)
#    ADD_SUBDIRECTORY(dae)
#ENDIF()

#IF(FBX_FOUND AND OSG_CPP_EXCEPTIONS_AVAILABLE)
#    ADD_SUBDIRECTORY(fbx)
#ENDIF()

#ADD_SUBDIRECTORY(dw)

# playbook edit #ADD_SUBDIRECTORY(bvh)
# ADD_SUBDIRECTORY(x)
# playbook edit #ADD_SUBDIRECTORY(dxf)
# playbook edit #ADD_SUBDIRECTORY(OpenFlight)
# ADD_SUBDIRECTORY(flt)
# playbook edit #ADD_SUBDIRECTORY(geo)
# ADD_SUBDIRECTORY(obj)

# playbook edit #ADD_SUBDIRECTORY(pic)
# playbook edit #ADD_SUBDIRECTORY(stl)
# IF(NOT ANDROID)
#    ADD_SUBDIRECTORY(3ds)
#ENDIF()
# playbook edit #ADD_SUBDIRECTORY(ac)
# playbook edit #ADD_SUBDIRECTORY(pov)

# playbook edit #ADD_SUBDIRECTORY(logo)
# playbook edit #ADD_SUBDIRECTORY(lws)
ADD_SUBDIRECTORY(md2)
ADD_SUBDIRECTORY(osgtgz)
ADD_SUBDIRECTORY(tgz)

#ADD_SUBDIRECTORY(shp)
#ADD_SUBDIRECTORY(txf)

#ADD_SUBDIRECTORY(bsp)
#ADD_SUBDIRECTORY(mdl)

#IF(OSG_CPP_EXCEPTIONS_AVAILABLE)
#    ADD_SUBDIRECTORY(lwo)
#    ADD_SUBDIRECTORY(ply)
#    ADD_SUBDIRECTORY(txp)
#ENDIF()

# playbook edit #IF(XINE_FOUND)
# playbook edit #    ADD_SUBDIRECTORY(xine)
# playbook edit #ENDIF()

#IF(FFMPEG_FOUND AND OSG_CPP_EXCEPTIONS_AVAILABLE)
#    ADD_SUBDIRECTORY(ffmpeg)
#ENDIF()

#IF(DIRECTSHOW_FOUND)
#    ADD_SUBDIRECTORY(directshow)
#ENDIF()

# IF(OPENAL_FOUND)
#    ADD_SUBDIRECTORY(OpenAL)
# ENDIF()

#IF(APPLE AND NOT ANDROID)
#    ADD_SUBDIRECTORY(imageio)
#ENDIF()

#IF(QUICKTIME_FOUND)
#    ADD_SUBDIRECTORY(quicktime)
#ENDIF()

#IF(QTKIT_FOUND)
#    ADD_SUBDIRECTORY(QTKit)
#ENDIF()

#IF(NVTT_FOUND)
#    ADD_SUBDIRECTORY(nvtt)
#ENDIF()


IF(FREETYPE_FOUND)
    ADD_SUBDIRECTORY(freetype)
ENDIF()

#IF (QT4_FOUND)
#    ADD_SUBDIRECTORY(qfont)
#ENDIF()

IF(ZLIB_FOUND)
    ADD_SUBDIRECTORY(zip)
ENDIF()

IF(RSVG_FOUND)
    ADD_SUBDIRECTORY(svg)
ENDIF()

#IF(POPPLER_FOUND)
#    ADD_SUBDIRECTORY(pdf)
#ENDIF()

#IF(LIBVNCSERVER_FOUND)
#    ADD_SUBDIRECTORY(vnc)
#ENDIF()

#ADD_SUBDIRECTORY(pvr)

##########to get all the variables of Cmake
#GET_CMAKE_PROPERTY(MYVARS VARIABLES)
#FOREACH(myvar ${MYVARS})
#    FILE(APPEND ${CMAKE_CURRENT_BINARY_DIR}/AllVariables.txt
#        "${myvar} -->${${myvar}}<-\n"
#    )
#ENDFOREACH(myvar)


